package com.lingshu.app.ui.report;

import android.graphics.BitmapFactory;

import androidx.lifecycle.ViewModelProvider;

import com.lingshu.app.R;
import com.lingshu.app.base.BaseFragment;
import com.lingshu.app.config.Constants;
import com.lingshu.app.databinding.FragmentFormScreenshotBinding;
import com.lingshu.app.model.register.RegisterScreenshotResponse;


public class FormScreenshotFragment extends BaseFragment<FragmentFormScreenshotBinding, FormScreenshotFragmentViewModel> {
    private RegisterScreenshotResponse screenshotResponse1;
    private RegisterScreenshotResponse screenshotResponse2;

    /**
     * 获取当前页面的布局资源ID
     *
     * @return 布局资源ID
     */
    @Override
    protected int getLayoutResId() {
        return R.layout.fragment_form_screenshot;
    }

    /**
     * 初始化ViewModel
     */
    @Override
    protected void initViewModel() {
        viewModel = new ViewModelProvider(this).get(FormScreenshotFragmentViewModel.class);
    }

    /**
     * 绑定ViewModel
     */
    @Override
    protected void bindViewModel() {
        dataBinding.setViewModel(viewModel);
    }

    /**
     * 初始化
     */
    @Override
    protected void init() {
        initRecyclerView();
        observerData();
        if (getArguments() != null) {
            if (getArguments().getSerializable(Constants.SCREENSHOT1) != null)
                screenshotResponse1 = (RegisterScreenshotResponse) getArguments().getSerializable(Constants.SCREENSHOT1);
            if (getArguments().getSerializable(Constants.SCREENSHOT2) != null)
                screenshotResponse2 = (RegisterScreenshotResponse) getArguments().getSerializable(Constants.SCREENSHOT2);
            if (screenshotResponse1 != null)
                dataBinding.imgScreenshot1.setImageBitmap(BitmapFactory.decodeFile(screenshotResponse1.getLocalStoragePath()));
            if (screenshotResponse2 != null)
                dataBinding.imgScreenshot2.setImageBitmap(BitmapFactory.decodeFile(screenshotResponse2.getLocalStoragePath()));
        }
    }

    private void observerData() {

    }

    private void initRecyclerView() {

    }
}